//
//  BLTextFieldControl.m
//  blanket
//
//  Created by Mac on 2017/12/6.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "BLTextFieldControl.h"
@interface BLTextFieldControl()
@property(nonatomic, strong) STLabel                     *leftLable;
@property(nonatomic, strong) STLabel                     *rightLable;
@end
@implementation BLTextFieldControl

- (instancetype)initWithFrame:(CGRect)frame leftTitle:(NSString *)leftTitle rightTitle:(NSString *)rightTitle{
    if (self == [super initWithFrame:frame]) {
        self.leftLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 20, self.height)
                                                   text:leftTitle
                                              textColor:KL_firstTextColor
                                                   font:14
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentLeft];
        [self addSubview:self.leftLable];
        [NSString lableAutoAdjustWitdhWithLabel:self.leftLable];
        
        self.rightLable = [[STLabel alloc] initWithFrame:CGRectMake(self.textFiled.right + 3, 0, 20, self.height)
                                                    text:rightTitle
                                               textColor:KL_firstTextColor
                                                    font:14
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentRight ];
        [self addSubview:self.rightLable];
        [NSString lableAutoAdjustWitdhWithLabel:self.rightLable];
        self.rightLable.right = self.width;
        
        self.textFiled = [[UITextField alloc] initWithFrame:CGRectMake(self.leftLable.right + 3, 0, self.rightLable.left - 6 - self.leftLable.right, self.height - 1)];
        self.textFiled.keyboardType = UIKeyboardTypeNumberPad;
        [self.textFiled st_setBorderWith:1 borderColor:BL_thirdTextColor cornerRadius:5];
        [self addSubview:self.textFiled];
        

        
    }
    return self;
}
- (instancetype)initWithLineFrame:(CGRect)frame leftTitle:(NSString *)leftTitle rightTitle:(NSString *)rightTitle{
    if (self == [super initWithFrame:frame]) {
        self.leftLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 20, self.height)
                                                   text:leftTitle
                                              textColor:KL_firstTextColor
                                                   font:14
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentLeft];
        [self addSubview:self.leftLable];
        [NSString lableAutoAdjustWitdhWithLabel:self.leftLable];
        
        self.rightLable = [[STLabel alloc] initWithFrame:CGRectMake(self.textFiled.right + 3, 0, 20, self.height)
                                                    text:rightTitle
                                               textColor:KL_firstTextColor
                                                    font:14
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentRight ];
        [self addSubview:self.rightLable];
        [NSString lableAutoAdjustWitdhWithLabel:self.rightLable];
        self.rightLable.right = self.width;
        
        self.textFiled = [[UITextField alloc] initWithFrame:CGRectMake(self.leftLable.right + 3, 0, self.rightLable.left - 6 - self.leftLable.right, self.height - 1)];
        self.textFiled.keyboardType = UIKeyboardTypeNumberPad;
        [self addSubview:self.textFiled];
        
        self.lineView = [[UIView alloc] initWithFrame:CGRectMake(self.textFiled.left, self.textFiled.bottom, self.textFiled.width, 0.5)];
        self.lineView.backgroundColor = KL_firstTextColor;
        [self addSubview:self.lineView];
        
    }
    return self;
}

@end


@interface BLButtonControl()
@property(nonatomic, strong) STLabel                     *leftLable;
@property(nonatomic, strong) STLabel                     *rightLable;
@property(nonatomic, strong) STButton                     *iconButton;
@end
@implementation BLButtonControl
- (instancetype)initWithLineFrame:(CGRect)frame leftTitle:(NSString *)leftTitle rightTitle:(NSString *)rightTitle leftImageName:(NSString *)imageName{
    if (self == [super initWithFrame:frame]) {

        STButton * iconButton = [[STButton alloc] initWithFrame:CGRectMake(0, 0, 44, self.height)
                                                         title:nil
                                                    titleColor:nil
                                                     titleFont:0
                                                  cornerRadius:0
                                               backgroundColor:nil
                                               backgroundImage:nil
                                                         image:[UIImage imageNamed:imageName]];
        iconButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        [self addSubview:iconButton];
        self.leftLable = [[STLabel alloc] initWithFrame:CGRectMake(iconButton.right, 0, 20, self.height)
                                                   text:leftTitle
                                              textColor:KL_firstTextColor
                                                   font:14
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentLeft];
        [self addSubview:self.leftLable];
        [NSString lableAutoAdjustWitdhWithLabel:self.leftLable];
        
        self.rightLable = [[STLabel alloc] initWithFrame:CGRectMake(self.textFiled.right + 3, 0, 20, self.height)
                                                    text:rightTitle
                                               textColor:KL_firstTextColor
                                                    font:14
                                             isSizetoFit:NO
                                           textAlignment:NSTextAlignmentRight ];
        [self addSubview:self.rightLable];
        [NSString lableAutoAdjustWitdhWithLabel:self.rightLable];
        self.rightLable.right = self.width;
        
        self.textFiled = [[UITextField alloc] initWithFrame:CGRectMake(self.leftLable.right + 3, 0, self.rightLable.left - 6 - self.leftLable.right, 20)];
        self.textFiled.keyboardType = UIKeyboardTypeNumberPad;
        self.textFiled.centerY = self.height /2;
        [self addSubview:self.textFiled];
        
        self.lineView = [[UIView alloc] initWithFrame:CGRectMake(self.textFiled.left, self.textFiled.bottom, self.textFiled.width, 0.5)];
        self.lineView.backgroundColor = KL_firstTextColor;
        [self addSubview:self.lineView];
        
    }
    return self;
}
@end

